{{ define "sso/logout.html" }}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SSO退出登录</title>
</head>
<body>

<div id="ifram-list">
{{range $i, $v := .data}}
    <iframe src="{{ $v }}" style="display: none" id="iframe{{ $i }}"></iframe>
{{ end }}
</div>

<script src="/static/sso/js/jquery-1.8.2.min.js"></script>
<script>

    let count = 0, index = 0;
    window.onload = function(){
        count = $('iframe').length;
        if (count === 0) logout();
        for(let i = 0; i < count; i++ ){
            addReady($('#iframe'+i));
        }

    };

    function addReady(iframeObj) {
        iframeObj.ready(function(){
            index++;
            if (index === count){
                logout();
            }
        });
    }
    function logout() {
        $.post('/auth/v1/sso/delete/login/url', {}, function (req) {
            if (req.code < 0){
                console.log(req.msg);
                $('#ifram-list').html(req.msg);
                return
            }
            location.reload()
        })
    }
</script>
</body>
</html>
{{ end }}